﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web;

namespace Mytrip.Users
{
    public static class LogonHelper
    {
        public static string LogonMenu(this HtmlHelper html)
        {

            StringBuilder result = new StringBuilder();
            if (HttpContext.Current.Request.IsAuthenticated)
            {
                TagBuilder li_logoff = new TagBuilder("li");
                TagBuilder li_welcome = new TagBuilder("li");
                TagBuilder logoff = new TagBuilder("a");
                logoff.MergeAttribute("href", "/Account/LogOff");
                logoff.InnerHtml = UserLanguage.logoff;
                TagBuilder welcome = new TagBuilder("a");
                welcome.InnerHtml = String.Format(UserLanguage.Welcome, HttpContext.Current.User.Identity.Name);
                li_logoff.InnerHtml = logoff.ToString();
                li_welcome.InnerHtml = welcome.ToString();
                result.AppendLine(li_logoff.ToString());
                result.AppendLine(li_welcome.ToString());
            }
            else
            {
                TagBuilder li = new TagBuilder("li");
                TagBuilder logon = new TagBuilder("a");
                logon.MergeAttribute("href", "/Account/LogOn");
                logon.InnerHtml = UserLanguage.logon;
                li.InnerHtml = logon.ToString();
                result.AppendLine(li.ToString());
            }
            return result.ToString();
        }
        /*<%
    if (Request.IsAuthenticated) {
%><li><%= Html.ActionLink(UserLanguage.logoff, "LogOff", "Account") %></li>
       <li><a><%= String.Format(UserLanguage.Welcome, Page.User.Identity.Name) %></a></li>
        
<%
    }
    else {
%> 
        <li><%= Html.ActionLink(UserLanguage.logon, "LogOn", "Account") %></li>
<%
    }
%>*/
    }
}
